package com.atguigu.chapter13

/**
 *
 * @description: xxx
 * @time: 2020-05-29 14:28
 * @author: baojinlong 
 **/
object ContrilAbstractApp {
  def main(args: Array[String]): Unit = {
    var x = 10
    while (x > 0) {
      x -= 1
      println("x=" + x)
    }
    println("#########")
    var i = 10
    // 就一行代码可以用括号来代替
    myUtil {
      i > 0
    } {
      i -= 1
      println("until x=" + i)
    }

  }

  @scala.annotation.tailrec
  // 其实就是传入代码块.代码块最终返回结果是boolean
  def myUtil(condition: => Boolean)(block: => Unit): Unit = {
    if (condition) {
      block
      myUtil(condition)(block)
    }
  }
}
